local BuffImmediately = require("gameLogic.buff.buffBase.BuffImmediately")
local BuffConfusion = class("BuffConfusion", BuffImmediately)
local SkillConfusion = require("gameLogic.fightSkill.show.SkillConfusion")

function BuffConfusion:ctor(entity, whoEntity, config)
    BuffConfusion.super.ctor(self, entity, whoEntity, config)
end

function BuffConfusion:_trigger()
    self._oldSkillList = self:getEntity():getSkills()
    local newSkillList = {}
    for i = 1, #self._oldSkillList do
        local newSkill = SkillConfusion.new(self._oldSkillList[i])
        table.insert(newSkillList, newSkill)
    end
    self:getEntity():setSkills(newSkillList)
end

function BuffConfusion:onDestroy()
    BuffConfusion.super.onDestroy(self)
    if self._oldSkillList then
        self:getEntity():setSkills(self._oldSkillList)
    end
end

return BuffConfusion
